Skip to content

Add benchmarks for specialization #9752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from

Conversation

liufengyun
Copy link
Contributor

Add benchmarks for specialization

Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring

// remove it will result in 200x speed up
arrByName(1) = null
arrByName(0).foo(6)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out we also need this turnaround to defeat JVM optimization.

inline def times(inline work: Int): Int = {
var res = 0
var count = 0
while count < x do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked what is being done here exactly but note that it's not recommended to use loops when benchmarking on the JVM: http://tutorials.jenkov.com/java-performance/jmh.html#writing-good-benchmarks, instead let JMH run things as many times as needed to get good statistics

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder, @smarter . It's really subtle to defeat optimization in microbenchmarks.

@liufengyun liufengyun closed this Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants